﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;

namespace CSLua
{
	// Token: 0x0200001A RID: 26
	public class SrcFileCache
	{
		// Token: 0x060000D7 RID: 215 RVA: 0x00005590 File Offset: 0x00003790
		public static SrcFileCache getSrc(string url)
		{
			SrcFileCache cache;
			if (SrcFileCache.caches.TryGetValue(url, out cache))
			{
				return cache;
			}
			if (File.Exists(url))
			{
				cache = new SrcFileCache(url);
			}
			else
			{
				cache = null;
			}
			SrcFileCache.caches.Add(url, cache);
			return cache;
		}

		// Token: 0x060000D8 RID: 216 RVA: 0x000055D0 File Offset: 0x000037D0
		private SrcFileCache(string url)
		{
			this.url = url;
			string[] lines = File.ReadAllLines(url, Encoding.UTF8);
			List<string> currentComman = new List<string>();
			for (int i = 0; i < lines.Length; i++)
			{
				string line = lines[i];
				string pattern = "^\\s*//";
				string tryLine = Regex.Replace(line, pattern, "");
				if (tryLine.Length != line.Length)
				{
					currentComman.Add(tryLine);
				}
				else if (currentComman.Count > 0)
				{
					this.commans.Add(i + 1, currentComman);
					currentComman = new List<string>();
				}
			}
		}

		// Token: 0x060000D9 RID: 217 RVA: 0x00005668 File Offset: 0x00003868
		public List<string> getComman(int line)
		{
			List<string> comman = null;
			this.commans.TryGetValue(line, out comman);
			return comman;
		}

		// Token: 0x060000DA RID: 218 RVA: 0x00005687 File Offset: 0x00003887
		public string getFileName()
		{
			return this.url;
		}

		// Token: 0x04000066 RID: 102
		private static Dictionary<string, SrcFileCache> caches = new Dictionary<string, SrcFileCache>();

		// Token: 0x04000067 RID: 103
		private string url;

		// Token: 0x04000068 RID: 104
		private Dictionary<int, List<string>> commans = new Dictionary<int, List<string>>();
	}
}
